<!DOCTYPE html>
<html lang="en">
  <head>
      <!-- set `maximum-scale` for some compatibility issues -->
  <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
  <meta name="format-detection" content="telephone=yes"/>

      <title>一舟SRM供应链管理平台</title>
        <script src='http://116.148.228.248:8000/CLodopfuncs.js?name=CLODOPTYDY'></script>

  <script>

  var zlcom="2",comParam="9600-N-8-1",zlzl = "03333345";
    var _weight = 0;//重量
    var timer_weight,timer_card,timer_msg,timer_button;
var xxxxxx="02 2B 30 20 20 20 20 32 33 31 20 20 20 20 30 30 0D"

window.onload = function() {
    // 阻止双击放大
    var lastTouchEnd = 0;
    document.addEventListener('touchstart', function(event) {
        if (event.touches.length > 1) {
            event.preventDefault();
        }
    });
    document.addEventListener('touchend', function(event) {
        var now = (new Date()).getTime();
        if (now - lastTouchEnd <= 300) {
            event.preventDefault();
        }
        lastTouchEnd = now;
    }, false);
 
    // 阻止双指放大
    document.addEventListener('gesturestart', function(event) {
        event.preventDefault();
    })

    var u = navigator.userAgent;
        // if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手机
        //     //  拿到获取焦点的input
        //     let input = document.querySelector('input')
        //     input.addEventListener('focus', function () {
        //         setInterval(function () {
        //         // 核心
        //             input.scrollIntoView(false);
        //         }, 200)
        //     })
        // }


  
       //打开串口
        zlcom = SerialComm.getconfig('COM');
        //alert(zlcom);
        var ret = SerialComm.opencomm(zlcom, comParam);
        if(ret=="false"){
            alert("电子称打开失败!");
            return;
        }else{
            alert("电子秤打开成功!");

            sendMsgHex();//打开成功后发送指令
        }



    
}

//发送指令方式
function sendMsg(){
    var ret = SerialComm.sendMsg(zlcom, zlzl);
    //SerialComm.sendMsg(zlcom, "R");
    //timer_button = setTimeout("sendMsgHex()", 100);
}


//发送指令方式
function sendMsgHex(){
    var ret = SerialComm.sendMsgHex(zlcom, zlzl);
    //SerialComm.sendMsg(zlcom, "R");
    //timer_button = setTimeout("sendMsgHex()", 100);
}
var _count = 0,_btn_val = 0;
//获取串口返回数据comNo串口号,data数据,字符类型
function getcommstr(comNo,data) {
    if(comNo == zlcom){
       // alert("返回接受字符：---"+data);  
         window.xxxxxx=data         
        SerialComm.sendMsg(zlcom, "R3");
    //alert(window.xxxxxx)

    }
}
//获取串口返回数据comNo串口号,data数据,字节类型
function getcomm(comNo,data) {
    if(comNo == zlcom){
        window.xxxxxx=data 
        //alert("返回接受字节：---"+data);     
        //SerialComm.sendMsg(zlcom, "R");   
    }
}
  </script>

      <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>

  <body>
    <div id='app'>

    </div>
    


  
</body>
  <script>


    </script>
</html>

